package com.tencent.wxcloudrun.controller;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.manager.ActiManager;
import com.tencent.wxcloudrun.vo.request.acti.*;
import com.tencent.wxcloudrun.vo.response.acti.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZhaoZiYin
 * @Date 2025/2/20
 * @Description 活动控制器
 */
@Api(tags = "活动控制器")
@Slf4j
@RestController
@Validated
@RequestMapping("/api/acti")
public class ActiController {

    @Resource
    private ActiManager actiManager;

    @ApiOperation("新增活动")
    @PostMapping(value = "/add")
    public ApiResponse<ActiAddResVo> add(@RequestBody @Valid ActiAddReqVo reqVo) {
        return ApiResponse.ok(actiManager.add(reqVo));
    }

    @ApiOperation("更新活动")
    @PostMapping(value = "/update")
    public ApiResponse<ActiUpdateResVo> update(@RequestBody @Valid ActiUpdateReqVo reqVo) {
        return ApiResponse.ok(actiManager.update(reqVo));
    }

    @ApiOperation("删除活动")
    @PostMapping(value = "/delete")
    public ApiResponse<ActiDeleteResVo> delete(@RequestBody @Valid ActiDeleteReqVo reqVo) {
        return ApiResponse.ok(actiManager.delete(reqVo));
    }

    @ApiOperation("发布活动")
    @PostMapping(value = "/release")
    public ApiResponse<ActiReleaseResVo> release(@RequestBody @Valid ActiReleaseReqVo reqVo) {
        return ApiResponse.ok(actiManager.release(reqVo));
    }

    @ApiOperation("参与入围活动")
    @PostMapping(value = "/joinSelected")
    public ApiResponse<ActiJoinSelectedResVo> joinSelected(@RequestBody @Valid ActiJoinSelectedReqVo reqVo) {
        return ApiResponse.ok(actiManager.joinSelectedToRedis(reqVo));
    }

    @ApiOperation("参与活动")
    @PostMapping(value = "/join")
    public ApiResponse<ActiJoinResVo> join(@RequestBody @Valid ActiJoinReqVo reqVo) {
        return ApiResponse.ok(actiManager.joinToRedis(reqVo));
    }

    @ApiOperation("参与黑箱活动")
    @PostMapping(value = "/joinBlack")
    public ApiResponse<ActiJoinBlackResVo> joinBlack(@RequestBody @Valid ActiJoinBlackReqVo reqVo) {
        return ApiResponse.ok(actiManager.joinBlackToRedis(reqVo));
    }

    @ApiOperation("保存活动用户返图")
    @PostMapping(value = "/saveUserImg")
    public ApiResponse<ActiSaveUserImgResVo> saveUserImg(@RequestBody @Valid ActiSaveUserImgReqVo reqVo) {
        return ApiResponse.ok(actiManager.saveUserImg(reqVo));
    }

}
